﻿using BalloonCS;
using OrderSystem.Common;
using OrderSystem.DataAccess;
using OrderSystem.SystemFramework;
using OrderSystem.Templet;
using System;
using System.Data.SqlClient;
using System.Drawing;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Xml;

namespace OrderSystem
{
    public partial class FormAddOrderItem : FormTemplet
    {
        private long _nOrderID = -1L;

        private int _nProductTypeID = -1;

        private FormOrderInfo frmOrderInfo;

        private Color errorColor = Color.FromArgb(199, 200, 203);

        private string _sTechnicsName = "";

        private double _dTechnicsUnitPrice = -1.0;

        private string _sTechnicsRemark = "";

        private bool _hasTechnicsData = false;

        private MessageBalloon _mb;

        private int nRowIndex = 0;

        private int nColumnIndex = 0;

        private FormAddOrderItem()
        {
            this.InitializeComponent();
        }

        public FormAddOrderItem(long nOrderID, FormOrderInfo frmOrderInfo) : this()
        {
            this._nOrderID = nOrderID;
            this.frmOrderInfo = frmOrderInfo;
        }

        private void btnSelect_Click(object sender, EventArgs e)
        {
            ProductTypeData productTypeData = FormSelectProductType.ShowBox();
            if (productTypeData != null)
            {
                this._nProductTypeID = productTypeData.ProductTypeID;
                this.txtProductType.Text = productTypeData.Name;
                this.txtQuantityUnit.Text = productTypeData.Unit;
                this.txtPrice.Text = productTypeData.DefaultPrice.ToString();
                this.cbProductCode.Focus();
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            base.Close();
        }

        private void btnSetting_Click(object sender, EventArgs e)
        {
            this.menuSettings_Click(null, null);
        }

        private void btnTechnics_Click(object sender, EventArgs e)
        {
            this.menuTechnics_Click(null, null);
        }

        private void FormAddOrderItem_Load(object sender, EventArgs e)
        {
            this.cbSave磨边.SelectedIndex = 0;
            this.cbFocusBox.SelectedIndex = 2;
            base.Width = 400;
            this.dgProductTechnics.AutoResizeColumns();
            this.dgProductTechnics.Columns.Add("technicsName", "工艺名称");
            this.dgProductTechnics.Columns["technicsName"].ReadOnly = true;
            this.dgProductTechnics.Columns.Add("technicsQuantity", "数量");
            this.dgProductTechnics.Columns["technicsQuantity"].ReadOnly = true;
            this.dgProductTechnics.Columns.Add("technicsUnitPrice", "单价");
            this.dgProductTechnics.Columns["technicsUnitPrice"].ReadOnly = true;
            this.dgProductTechnics.Columns.Add("technicsRemark", "备注");
            this.dgProductTechnics.Columns["technicsRemark"].ReadOnly = true;
            this.dgProductTechnics.Columns.Add(new DataGridViewCheckBoxColumn(false));
            this.dgProductTechnics.Columns[4].HeaderText = "是否保存";
            this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[0].Cells[0];
            for (int i = 0; i < this.dgProductTechnics.Columns.Count; i++)
            {
                this.dgProductTechnics.Columns[i].SortMode = DataGridViewColumnSortMode.Programmatic;
            }
        }

        private void FormAddOrderItem_FormClosing(object sender, FormClosingEventArgs e)
        {
        }

        private void FormAddOrderItem_Activated(object sender, EventArgs e)
        {
            base.WindowState = FormWindowState.Normal;
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            base.AcceptButton = this.btnOk;
            this.cbProductCode.Text = CommonMethod.Fun1(this.cbProductCode.Text);
            this.txtWidth.Text = CommonMethod.Fun1(this.txtWidth.Text);
            this.txtSubtenseOfWidth.Text = CommonMethod.Fun1(this.txtSubtenseOfWidth.Text);
            this.txtHeight.Text = CommonMethod.Fun1(this.txtHeight.Text);
            this.txtSubtenseOfHeight.Text = CommonMethod.Fun1(this.txtSubtenseOfHeight.Text);
            this.txtQuantity.Text = CommonMethod.Fun1(this.txtQuantity.Text);
            this.txtPrice.Text = CommonMethod.Fun1(this.txtPrice.Text);
            this.cbRemark.Text = CommonMethod.Fun1(this.cbRemark.Text);
            if (this._mb != null)
            {
                this._mb.Dispose();
                this._mb = null;
            }
            if (this.txtProductType.Text.Trim() == "" || this._nProductTypeID == -1)
            {
                this.btnSelect.Focus();
                this.txtProductType.BackColor = this.errorColor;
                this.txtProductType.ImeMode = ImeMode.Alpha;
            }
            else
            {
                this.txtProductType.BackColor = SystemColors.InactiveCaptionText;
                if (this.chk逐行跳动.Checked)
                {
                    if (this.txtProductType.Focused)
                    {
                        this.cbProductCode.Focus();
                        return;
                    }
                }
            }
            if (this.cbProductCode.Text.Trim().Length > 32)
            {
                this.cbProductCode.Focus();
                this.cbProductCode.BackColor = this.errorColor;
                this.cbProductCode.ImeMode = ImeMode.Alpha;
            }
            else
            {
                bool flag = false;
                for (int i = 0; i < this.cbProductCode.Items.Count; i++)
                {
                    if (this.cbProductCode.Items[i].ToString() == this.cbProductCode.Text.Trim())
                    {
                        flag = true;
                    }
                }
                if (!flag)
                {
                    this.cbProductCode.Items.Add(this.cbProductCode.Text.Trim());
                }
                this.cbProductCode.BackColor = Color.White;
                if (this.chk逐行跳动.Checked)
                {
                    if (this.cbProductCode.Focused)
                    {
                        this.txtWidth.Focus();
                        return;
                    }
                }
            }
            if (!Regex.IsMatch(this.txtWidth.Text.Trim(), "^(([0-9]{1,8})|([0-9]{1,8}\\.[0-9]{1,2}))$") || Convert.ToDecimal(this.txtWidth.Text.Trim()) <= 0m)
            {
                this.txtWidth.Focus();
                this.txtWidth.BackColor = this.errorColor;
                this.txtWidth.ImeMode = ImeMode.Alpha;
            }
            else
            {
                this.txtWidth.BackColor = Color.White;
                if (this.chk逐行跳动.Checked)
                {
                    if (this.txtWidth.Focused)
                    {
                        this.txtHeight.Focus();
                        return;
                    }
                }
            }
            if (this.txtSubtenseOfWidth.Text.Trim().Length > 0)
            {
                if (!Regex.IsMatch(this.txtSubtenseOfWidth.Text.Trim(), "^(([0-9]{1,8})|([0-9]{1,8}\\.[0-9]{1,2}))$") || Convert.ToDecimal(this.txtSubtenseOfWidth.Text.Trim()) <= 0m)
                {
                    this.txtSubtenseOfWidth.Focus();
                    this.txtSubtenseOfWidth.BackColor = this.errorColor;
                    this.txtSubtenseOfWidth.ImeMode = ImeMode.Alpha;
                    return;
                }
                this.txtSubtenseOfWidth.BackColor = Color.White;
                if (Convert.ToDecimal(this.txtSubtenseOfWidth.Text.Trim()) > Convert.ToDecimal(this.txtWidth.Text.Trim()))
                {
                    string text = this.txtWidth.Text;
                    this.txtWidth.Text = this.txtSubtenseOfWidth.Text;
                    this.txtSubtenseOfWidth.Text = text;
                }
            }
            else
            {
                this.txtSubtenseOfWidth.BackColor = Color.White;
            }

            if (!Regex.IsMatch(this.txtHeight.Text.Trim(), "^(([0-9]{1,8})|([0-9]{1,8}\\.[0-9]{1,2}))$") || Convert.ToDecimal(this.txtHeight.Text.Trim()) <= 0m)
            {
                this.txtHeight.Focus();
                this.txtHeight.BackColor = this.errorColor;
                this.txtHeight.ImeMode = ImeMode.Alpha;
            }
            else
            {
                this.txtHeight.BackColor = Color.White;
                if (this.chk逐行跳动.Checked)
                {
                    if (this.txtHeight.Focused)
                    {
                        this.txtQuantity.Focus();
                        return;
                    }
                }
            }

            if (this.txtSubtenseOfHeight.Text.Trim().Length > 0)
            {
                if (!Regex.IsMatch(this.txtSubtenseOfHeight.Text.Trim(), "^(([0-9]{1,8})|([0-9]{1,8}\\.[0-9]{1,2}))$") || Convert.ToDecimal(this.txtSubtenseOfHeight.Text.Trim()) <= 0m)
                {
                    this.txtSubtenseOfHeight.Focus();
                    this.txtSubtenseOfHeight.BackColor = this.errorColor;
                    this.txtSubtenseOfHeight.ImeMode = ImeMode.Alpha;
                    return;
                }
                this.txtSubtenseOfHeight.BackColor = Color.White;
                if (Convert.ToDecimal(this.txtSubtenseOfHeight.Text.Trim()) > Convert.ToDecimal(this.txtHeight.Text.Trim()))
                {
                    string text = this.txtHeight.Text;
                    this.txtHeight.Text = this.txtSubtenseOfHeight.Text;
                    this.txtSubtenseOfHeight.Text = text;
                }
            }
            else
            {
                this.txtSubtenseOfHeight.BackColor = Color.White;
            }
            //
            if (this.txtSpecialShapedName.Text.Trim().Length > 32)
            {
                this.txtSpecialShapedName.Focus();
                this.txtSpecialShapedName.BackColor = this.errorColor;
                this.txtSpecialShapedName.ImeMode = ImeMode.Alpha;
            }
            else
            {
                this.txtSpecialShapedName.BackColor = Color.White;
                if (this.chk逐行跳动.Checked)
                {
                    if (this.txtSpecialShapedName.Focused)
                    {
                        this.txtQuantity.Focus();
                        return;
                    }
                }
            }
            //
            if (!Regex.IsMatch(this.txtQuantity.Text.Trim(), "^[0-9]{1,8}$") || Convert.ToInt32(this.txtQuantity.Text.Trim()) <= 0)
            {
                this.txtQuantity.Focus();
                this.txtQuantity.BackColor = this.errorColor;
                this.txtQuantity.ImeMode = ImeMode.Alpha;
            }
            else
            {
                this.txtQuantity.BackColor = Color.White;
                if (this.chk逐行跳动.Checked)
                {
                    if (this.txtQuantity.Focused)
                    {
                        this.txtPrice.Focus();
                        return;
                    }
                }
            }
            //
            if (!Regex.IsMatch(this.txtPrice.Text.Trim(), "^(([0-9]{1,})|([0-9]{1,}\\.[0-9]{1,4}))$") || Convert.ToDecimal(this.txtPrice.Text.Trim()) < 0m)
            {
                this.txtPrice.Focus();
                this.txtPrice.BackColor = this.errorColor;
                this.txtPrice.ImeMode = ImeMode.Alpha;
            }
            else
            {
                this.txtPrice.BackColor = Color.White;
                if (this.chk逐行跳动.Checked)
                {
                    if (this.txtPrice.Focused)
                    {
                        this.cbRemark.Focus();
                        return;
                    }
                }
            }
            //

            if (this.cbRemark.Text.Trim().Length > 64)
            {
                this.cbRemark.Focus();
                this.cbRemark.BackColor = this.errorColor;
                this.cbRemark.ImeMode = ImeMode.Alpha;
            }
            else
            {
                bool flag = false;
                for (int i = 0; i < this.cbRemark.Items.Count; i++)
                {
                    if (this.cbRemark.Items[i].ToString() == this.cbRemark.Text.Trim())
                    {
                        flag = true;
                    }
                }
                if (!flag)
                {
                    this.cbRemark.Items.Add(this.cbRemark.Text.Trim());
                }
                this.cbRemark.BackColor = Color.White;

            }

            //加工要求
            if (this.dgProductTechnics != null && this.dgProductTechnics.Rows.Count > 0)
            {
                this._hasTechnicsData = false;
                for (int i = 0; i < this.dgProductTechnics.Rows.Count; i++)
                {
                    if (this.dgProductTechnics.Rows[i].Cells[4].Value != null && (bool)this.dgProductTechnics.Rows[i].Cells[4].Value)
                    {
                        this.dgProductTechnics.Rows[i].Cells[0].Value = CommonMethod.Fun1((this.dgProductTechnics.Rows[i].Cells[0].Value == null) ? "" : this.dgProductTechnics.Rows[i].Cells[0].Value.ToString());
                        this.dgProductTechnics.Rows[i].Cells[1].Value = CommonMethod.Fun1((this.dgProductTechnics.Rows[i].Cells[1].Value == null) ? "" : this.dgProductTechnics.Rows[i].Cells[1].Value.ToString());
                        this.dgProductTechnics.Rows[i].Cells[2].Value = CommonMethod.Fun1((this.dgProductTechnics.Rows[i].Cells[2].Value == null) ? "" : this.dgProductTechnics.Rows[i].Cells[2].Value.ToString());
                        this.dgProductTechnics.Rows[i].Cells[3].Value = CommonMethod.Fun1((this.dgProductTechnics.Rows[i].Cells[3].Value == null) ? "" : this.dgProductTechnics.Rows[i].Cells[3].Value.ToString());
                        if (this.dgProductTechnics.Rows[i].Cells[0].Value.ToString().Trim().Length > 32 || this.dgProductTechnics.Rows[i].Cells[0].Value.ToString().Trim().Length < 1)
                        {
                            this.menuTechnics_Click(null, null);
                            this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[i].Cells[0];
                            return;
                        }
                        if (!Regex.IsMatch(this.dgProductTechnics.Rows[i].Cells[1].Value.ToString().Trim(), "^(([0-9]{1,8})|([0-9]{1,}\\.[0-9]{1,4}))$") || Convert.ToDouble(this.dgProductTechnics.Rows[i].Cells[1].Value.ToString().Trim()) <= 0.0)
                        {
                            this.menuTechnics_Click(null, null);
                            this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[i].Cells[1];
                            return;
                        }
                        if (!Regex.IsMatch(this.dgProductTechnics.Rows[i].Cells[2].Value.ToString().Trim(), "^(([0-9]{1,8})|([0-9]{1,}\\.[0-9]{1,4}))$") || Convert.ToDouble(this.dgProductTechnics.Rows[i].Cells[1].Value.ToString().Trim()) < 0.0)
                        {
                            this.menuTechnics_Click(null, null);
                            this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[i].Cells[2];
                            return;
                        }
                        if (this.dgProductTechnics.Rows[i].Cells[3].Value.ToString().Length > 32)
                        {
                            this.menuTechnics_Click(null, null);
                            this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[i].Cells[3];
                            return;
                        }
                        this._hasTechnicsData = true;
                    }

                    OrderItems orderItems = new OrderItems();
                    string text2 = null;
                    try
                    {
                        string xml = this.GetTechnicsXMLDocument();
                        decimal mWidth = 0;
                        decimal.TryParse(this.txtWidth.Text.Trim(), out mWidth);

                        text2 = orderItems.InsertOrderItem(this._nOrderID, this._nProductTypeID, this.cbProductCode.Text.Trim(), mWidth, 
                            (this.txtSubtenseOfWidth.Text.Trim().Length < 1) ? "" : this.txtSubtenseOfWidth.Text.Trim(), 
                            Convert.ToDecimal(this.txtHeight.Text.Trim()), (this.txtSubtenseOfHeight.Text.Trim().Length < 1) ? "" : this.txtSubtenseOfHeight.Text.Trim(), 
                            this.txtSpecialShapedName.Text.Trim(), Convert.ToInt32(this.txtQuantity.Text.Trim()), Convert.ToDecimal(this.txtPrice.Text.Trim()), 
                            this.cbRemark.Text.Trim(), LoginInfo.OperatorID, xml);
                        orderItems.InsertTechnics(text2,"0",this.dgProductTechnics.Rows[i].Cells[0].Value.ToString(), this.dgProductTechnics.Rows[i].Cells[1].Value.ToString(),
                            this.dgProductTechnics.Rows[i].Cells[2].Value.ToString(), this.dgProductTechnics.Rows[i].Cells[3].Value.ToString());
                    }
                    catch (SqlException ex)
                    {
                        int number = ex.Number;
                        if (number != 50001)
                        {
                            switch (number)
                            {
                                case 50100:
                                    MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                    this.frmOrderInfo.chkLockedData.Checked = true;
                                    break;
                                case 50101:
                                    MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                    this.frmOrderInfo.chkCancelled.Checked = true;
                                    break;
                                case 50102:
                                    MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                    this.frmOrderInfo.menuEditData.Checked = false;
                                    break;
                                case 50103:
                                    MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                    break;
                                default:
                                    MessageBox.Show(ex.Message + "\r\n\r\n或者是连接数据库的通道出现故障，请检查！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                                    break;
                            }
                        }
                        else
                        {
                            MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }
                    catch (Exception ex2)
                    {
                        MessageBox.Show(ex2.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    orderItems.Dispose();
                    if (text2 != null && text2.Length > 0)
                    {
                        this.frmOrderInfo.ReloadOrderItemsForInsert(text2, this.txtProductType.Text.Trim(), this.txtQuantityUnit.Text.Trim(), this.cbProductCode.Text.Trim(), Convert.ToDecimal(this.txtWidth.Text.Trim()), this.txtSubtenseOfWidth.Text.Trim(), Convert.ToDecimal(this.txtHeight.Text.Trim()), this.txtSubtenseOfHeight.Text.Trim(), this.txtSpecialShapedName.Text.Trim(), Convert.ToInt32(this.txtQuantity.Text.Trim()), Convert.ToDecimal(this.txtPrice.Text.Trim()), this.cbRemark.Text.Trim(), this.GetTechnics());
                        if (!this.chkSaveType.Checked)
                        {
                            this._nProductTypeID = -1;
                            this.txtProductType.Text = "";
                        }
                        if (!this.chkSaveCode.Checked)
                        {
                            this.cbProductCode.Text = "";
                        }
                        if (!this.chkSaveWidth.Checked)
                        {
                            this.txtWidth.Text = "";
                        }
                        if (!this.chkSaveSubtenseOfWidth.Checked)
                        {
                            this.txtSubtenseOfWidth.Text = "";
                        }
                        if (!this.chkSaveHeightt.Checked)
                        {
                            this.txtHeight.Text = "";
                        }
                        if (!this.chkSaveSubtenseOfHeightt.Checked)
                        {
                            this.txtSubtenseOfHeight.Text = "";
                        }
                        if (!this.chkSaveQuantity.Checked)
                        {
                            this.txtQuantity.Text = "";
                        }
                        if (!this.chkSavePrice.Checked)
                        {
                            this.txtPrice.Text = "";
                        }
                        if (!this.chkSaveRemark.Checked)
                        {
                            this.cbRemark.Text = "";
                        }
                        if (this.cbFocusBox.SelectedIndex == 1)
                        {
                            this.btnSelect.Focus();
                        }
                        if (this.cbFocusBox.SelectedIndex == 2)
                        {
                            this.cbProductCode.Focus();
                        }
                        if (this.cbFocusBox.SelectedIndex == 3)
                        {
                            this.txtWidth.Focus();
                        }
                        if (this.cbFocusBox.SelectedIndex == 4)
                        {
                            this.txtHeight.Focus();
                        }
                        if (this.cbFocusBox.SelectedIndex == 5)
                        {
                            this.txtQuantity.Focus();
                        }
                        if (this.cbFocusBox.SelectedIndex == 6)
                        {
                            this.txtPrice.Focus();
                        }
                        if (this.cbFocusBox.SelectedIndex == 7)
                        {
                            this.cbRemark.Focus();
                        }
                    }
                }
            }
        }

        private string GetTechnics()
        {
            string text = "";
            for (int i = 0; i < this.dgProductTechnics.Rows.Count; i++)
            {
                if (this.dgProductTechnics.Rows[i].Cells[4].Value != null && (bool)this.dgProductTechnics.Rows[i].Cells[4].Value)
                {
                    if (text.Length > 0)
                    {
                        text = text + "/" + this.dgProductTechnics.Rows[i].Cells[0].Value.ToString();
                    }
                    else
                    {
                        text = this.dgProductTechnics.Rows[i].Cells[0].Value.ToString();
                    }
                }
            }
            if (this.cbSave磨边.SelectedIndex > 0 && this.cbSave磨边.SelectedIndex < this.cbSave磨边.Items.Count - 1)
            {
                if (text.Length > 0)
                {
                    text = text + "/" + this._sTechnicsName;
                }
                else
                {
                    text = this._sTechnicsName;
                }
            }
            return text;
        }

        private string GetTechnicsXMLDocument()
        {
            string result;
            if (!this._hasTechnicsData && (this.cbSave磨边.SelectedIndex == 0 || this.cbSave磨边.SelectedIndex == this.cbSave磨边.Items.Count - 1))
            {
                result = "";
            }
            else
            {
                XmlDocument xmlDocument = new XmlDocument();
                XmlNode xmlNode = xmlDocument.CreateElement("technics");
                xmlDocument.AppendChild(xmlNode);
                for (int i = 0; i < this.dgProductTechnics.Rows.Count; i++)
                {
                    if (this.dgProductTechnics.Rows[i].Cells[4].Value != null && (bool)this.dgProductTechnics.Rows[i].Cells[4].Value)
                    {
                        XmlNode xmlNode2 = xmlDocument.CreateElement("item");
                        XmlAttribute xmlAttribute = xmlDocument.CreateAttribute("sequenceCode");
                        xmlAttribute.InnerText = i.ToString();
                        xmlNode2.Attributes.Append(xmlAttribute);
                        XmlAttribute xmlAttribute2 = xmlDocument.CreateAttribute("technicsName");
                        xmlAttribute2.InnerText = this.dgProductTechnics.Rows[i].Cells[0].Value.ToString();
                        xmlNode2.Attributes.Append(xmlAttribute2);
                        XmlAttribute xmlAttribute3 = xmlDocument.CreateAttribute("quantity");
                        xmlAttribute3.InnerText = this.dgProductTechnics.Rows[i].Cells[1].Value.ToString();
                        xmlNode2.Attributes.Append(xmlAttribute3);
                        XmlAttribute xmlAttribute4 = xmlDocument.CreateAttribute("unitPrice");
                        xmlAttribute4.InnerText = this.dgProductTechnics.Rows[i].Cells[2].Value.ToString();
                        xmlNode2.Attributes.Append(xmlAttribute4);
                        XmlAttribute xmlAttribute5 = xmlDocument.CreateAttribute("remark");
                        xmlAttribute5.InnerText = this.dgProductTechnics.Rows[i].Cells[3].Value.ToString();
                        xmlNode2.Attributes.Append(xmlAttribute5);
                        xmlNode.AppendChild(xmlNode2);
                    }
                }
                if (this.cbSave磨边.SelectedIndex > 0 && this.cbSave磨边.SelectedIndex < this.cbSave磨边.Items.Count - 1)
                {
                    double num = Convert.ToDouble(this.txtWidth.Text.Trim());
                    double num2 = Convert.ToDouble(this.txtHeight.Text.Trim());
                    double num3 = 0.0;
                    string text = this.cbSave磨边.Text;
                    switch (text)
                    {
                        case "一长边":
                            if (num > num2)
                            {
                                num3 = num / 1000.0;
                            }
                            else
                            {
                                num3 = num2 / 1000.0;
                            }
                            break;
                        case "一短边":
                            if (num > num2)
                            {
                                num3 = num2 / 1000.0;
                            }
                            else
                            {
                                num3 = num / 1000.0;
                            }
                            break;
                        case "两长边":
                            if (num > num2)
                            {
                                num3 = num * 2.0 / 1000.0;
                            }
                            else
                            {
                                num3 = num2 * 2.0 / 1000.0;
                            }
                            break;
                        case "两短边":
                            if (num > num2)
                            {
                                num3 = num2 * 2.0 / 1000.0;
                            }
                            else
                            {
                                num3 = num * 2.0 / 1000.0;
                            }
                            break;
                        case "两长边+一短边":
                            if (num > num2)
                            {
                                num3 = (num * 2.0 + num2) / 1000.0;
                            }
                            else
                            {
                                num3 = (num2 * 2.0 + num) / 1000.0;
                            }
                            break;
                        case "两短边+一长边":
                            if (num > num2)
                            {
                                num3 = (num2 * 2.0 + num) / 1000.0;
                            }
                            else
                            {
                                num3 = (num * 2.0 + num2) / 1000.0;
                            }
                            break;
                        case "一长边+一短边":
                            num3 = (num + num2) / 1000.0;
                            break;
                        case "周长":
                            num3 = (num * 2.0 + num2 * 2.0) / 1000.0;
                            break;
                        case "圆周长":
                            num3 = num * 3.14 / 1000.0;
                            break;
                    }
                    XmlNode xmlNode2 = xmlDocument.CreateElement("item");
                    XmlAttribute xmlAttribute = xmlDocument.CreateAttribute("sequenceCode");
                    XmlNode arg_5AF_0 = xmlAttribute;
                    int count = this.dgProductTechnics.Rows.Count;
                    arg_5AF_0.InnerText = count.ToString();
                    xmlNode2.Attributes.Append(xmlAttribute);
                    XmlAttribute xmlAttribute2 = xmlDocument.CreateAttribute("technicsName");
                    xmlAttribute2.InnerText = this._sTechnicsName;
                    xmlNode2.Attributes.Append(xmlAttribute2);
                    XmlAttribute xmlAttribute3 = xmlDocument.CreateAttribute("quantity");
                    xmlAttribute3.InnerText = num3.ToString();
                    xmlNode2.Attributes.Append(xmlAttribute3);
                    XmlAttribute xmlAttribute4 = xmlDocument.CreateAttribute("unitPrice");
                    xmlAttribute4.InnerText = this._dTechnicsUnitPrice.ToString();
                    xmlNode2.Attributes.Append(xmlAttribute4);
                    XmlAttribute xmlAttribute5 = xmlDocument.CreateAttribute("remark");
                    xmlAttribute5.InnerText = this._sTechnicsRemark;
                    xmlNode2.Attributes.Append(xmlAttribute5);
                    xmlNode.AppendChild(xmlNode2);
                }
                result = xmlDocument.InnerXml;
            }
            return result;
        }

        private void btnHide_Click(object sender, EventArgs e)
        {
            this.menuGetBackForm_Click(null, null);
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.dgProductTechnics.Rows.Count > 0)
            {
                foreach (DataGridViewRow dataGridViewRow in this.dgProductTechnics.SelectedRows)
                {
                    if (!dataGridViewRow.IsNewRow)
                    {
                        this.dgProductTechnics.Rows.Remove(dataGridViewRow);
                    }
                }
            }
        }

        private void btnMoveDown_Click(object sender, EventArgs e)
        {
            if (this.dgProductTechnics.Rows.Count >= 2 && this.dgProductTechnics.CurrentCell.RowIndex != this.dgProductTechnics.Rows.Count - 1)
            {
                int rowIndex = this.dgProductTechnics.CurrentCell.RowIndex;
                string text = (this.dgProductTechnics.Rows[rowIndex].Cells[0].Value == null) ? "" : this.dgProductTechnics.Rows[rowIndex].Cells[0].Value.ToString();
                string text2 = (this.dgProductTechnics.Rows[rowIndex].Cells[1].Value == null) ? "" : this.dgProductTechnics.Rows[rowIndex].Cells[1].Value.ToString();
                string text3 = (this.dgProductTechnics.Rows[rowIndex].Cells[2].Value == null) ? "" : this.dgProductTechnics.Rows[rowIndex].Cells[2].Value.ToString();
                string text4 = (this.dgProductTechnics.Rows[rowIndex].Cells[3].Value == null) ? "" : this.dgProductTechnics.Rows[rowIndex].Cells[3].Value.ToString();
                bool flag = this.dgProductTechnics.Rows[rowIndex].Cells[4].Value != null && (bool)this.dgProductTechnics.Rows[rowIndex].Cells[4].Value;
                string text5 = (this.dgProductTechnics.Rows[rowIndex + 1].Cells[0].Value == null) ? "" : this.dgProductTechnics.Rows[rowIndex + 1].Cells[0].Value.ToString();
                string text6 = (this.dgProductTechnics.Rows[rowIndex + 1].Cells[1].Value == null) ? "" : this.dgProductTechnics.Rows[rowIndex + 1].Cells[1].Value.ToString();
                string text7 = (this.dgProductTechnics.Rows[rowIndex + 1].Cells[2].Value == null) ? "" : this.dgProductTechnics.Rows[rowIndex + 1].Cells[2].Value.ToString();
                string text8 = (this.dgProductTechnics.Rows[rowIndex + 1].Cells[3].Value == null) ? "" : this.dgProductTechnics.Rows[rowIndex + 1].Cells[3].Value.ToString();
                bool flag2 = this.dgProductTechnics.Rows[rowIndex + 1].Cells[4].Value != null && (bool)this.dgProductTechnics.Rows[rowIndex + 1].Cells[4].Value;
                this.dgProductTechnics.Rows[this.dgProductTechnics.CurrentCell.RowIndex].SetValues(new object[]
                {
                    text5,
                    text6,
                    text7,
                    text8,
                    flag2
                });
                this.dgProductTechnics.Rows[this.dgProductTechnics.CurrentCell.RowIndex + 1].SetValues(new object[]
                {
                    text,
                    text2,
                    text3,
                    text4,
                    flag
                });
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[rowIndex + 1].Cells[this.dgProductTechnics.CurrentCell.ColumnIndex];
                this.dgProductTechnics.Rows[rowIndex + 1].Selected = true;
            }
        }

        private void btnMoveUp_Click(object sender, EventArgs e)
        {
            if (this.dgProductTechnics.Rows.Count >= 2 && this.dgProductTechnics.CurrentCell.RowIndex != 0)
            {
                int rowIndex = this.dgProductTechnics.CurrentCell.RowIndex;
                string text = (this.dgProductTechnics.Rows[rowIndex].Cells[0].Value == null) ? "" : this.dgProductTechnics.Rows[rowIndex].Cells[0].Value.ToString();
                string text2 = (this.dgProductTechnics.Rows[rowIndex].Cells[1].Value == null) ? "" : this.dgProductTechnics.Rows[rowIndex].Cells[1].Value.ToString();
                string text3 = (this.dgProductTechnics.Rows[rowIndex].Cells[2].Value == null) ? "" : this.dgProductTechnics.Rows[rowIndex].Cells[2].Value.ToString();
                string text4 = (this.dgProductTechnics.Rows[rowIndex].Cells[3].Value == null) ? "" : this.dgProductTechnics.Rows[rowIndex].Cells[3].Value.ToString();
                bool flag = this.dgProductTechnics.Rows[rowIndex].Cells[4].Value != null && (bool)this.dgProductTechnics.Rows[rowIndex].Cells[4].Value;
                string text5 = (this.dgProductTechnics.Rows[rowIndex - 1].Cells[0].Value == null) ? "" : this.dgProductTechnics.Rows[rowIndex - 1].Cells[0].Value.ToString();
                string text6 = (this.dgProductTechnics.Rows[rowIndex - 1].Cells[1].Value == null) ? "" : this.dgProductTechnics.Rows[rowIndex - 1].Cells[1].Value.ToString();
                string text7 = (this.dgProductTechnics.Rows[rowIndex - 1].Cells[2].Value == null) ? "" : this.dgProductTechnics.Rows[rowIndex - 1].Cells[2].Value.ToString();
                string text8 = (this.dgProductTechnics.Rows[rowIndex - 1].Cells[3].Value == null) ? "" : this.dgProductTechnics.Rows[rowIndex - 1].Cells[3].Value.ToString();
                bool flag2 = this.dgProductTechnics.Rows[rowIndex - 1].Cells[4].Value != null && (bool)this.dgProductTechnics.Rows[rowIndex - 1].Cells[4].Value;
                this.dgProductTechnics.Rows[this.dgProductTechnics.CurrentCell.RowIndex].SetValues(new object[]
                {
                    text5,
                    text6,
                    text7,
                    text8,
                    flag2
                });
                this.dgProductTechnics.Rows[this.dgProductTechnics.CurrentCell.RowIndex - 1].SetValues(new object[]
                {
                    text,
                    text2,
                    text3,
                    text4,
                    flag
                });
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[rowIndex - 1].Cells[this.dgProductTechnics.CurrentCell.ColumnIndex];
                this.dgProductTechnics.Rows[rowIndex - 1].Selected = true;
            }
        }

        private void btnSaveSetting_Click(object sender, EventArgs e)
        {
            this.menuGetBackForm_Click(null, null);
        }

        private void cbSave磨边_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.cbSave磨边.SelectedIndex > 0 && this.cbSave磨边.SelectedIndex <= this.cbSave磨边.Items.Count - 2)
            {
                string text = InputBox.ShowBox("请输入你要自动保存磨边的名称...", (this._sTechnicsName.ToString() == "") ? "磨边" : this._sTechnicsName.ToString());
                if (text == null)
                {
                    this.cbSave磨边.SelectedIndex = 0;
                }
                else if (text.Trim().Length > 32)
                {
                    MessageBox.Show("工艺名称 格式不正确，字符太长，应在 32 个字符之内！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    this.cbSave磨边.SelectedIndex = 0;
                }
                else
                {
                    this._sTechnicsName = text.Trim();
                    text = InputBox.ShowBox("请输入你要自动保存磨边的价格...", (this._dTechnicsUnitPrice > -1.0) ? this._dTechnicsUnitPrice.ToString() : "");
                    text = CommonMethod.Fun1(text);
                    if (text == null)
                    {
                        this.cbSave磨边.SelectedIndex = 0;
                    }
                    else if (!Regex.IsMatch(text.Trim(), "^(([0-9]{1,8})|([0-9]{1,}\\.[0-9]{1,4}))$") || Convert.ToDouble(text.Trim()) < 0.0)
                    {
                        MessageBox.Show("单价 格式不正确，此处应该为大于零的数字，如有小数，最大为4位小数", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        this.cbSave磨边.SelectedIndex = 0;
                    }
                    else
                    {
                        this._dTechnicsUnitPrice = Convert.ToDouble(text.Trim());
                        text = InputBox.ShowBox("请输入你要自动保存磨边的备注...", this._sTechnicsRemark.ToString());
                        if (text == null)
                        {
                            this.cbSave磨边.SelectedIndex = 0;
                        }
                        else if (text.Trim().Length > 32)
                        {
                            MessageBox.Show("工艺备注 格式不正确，字符太长，应在 32 个字符之内！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            this.cbSave磨边.SelectedIndex = 0;
                        }
                        else
                        {
                            this._sTechnicsRemark = text.Trim();
                        }
                    }
                }
            }
        }

        private void ConvertToBJ(object sender, EventArgs e)
        {
            ((Control)sender).ImeMode = ImeMode.Alpha;
        }

        private void menuFocusProductType_Click(object sender, EventArgs e)
        {
            this.btnSelect.Focus();
        }

        private void menuFocusProductCode_Click(object sender, EventArgs e)
        {
            this.cbProductCode.Focus();
        }

        private void menuFocusWidth_Click(object sender, EventArgs e)
        {
            this.txtWidth.Focus();
        }

        private void menuFocusHeight_Click(object sender, EventArgs e)
        {
            this.txtHeight.Focus();
        }

        private void menuFocusQuantity_Click(object sender, EventArgs e)
        {
            this.txtQuantity.Focus();
        }

        private void menuFocusPrice_Click(object sender, EventArgs e)
        {
            this.txtPrice.Focus();
        }

        private void menuFocusRemark_Click(object sender, EventArgs e)
        {
            this.cbRemark.Focus();
        }

        private void menuSettings_Click(object sender, EventArgs e)
        {
            base.Width = 637;
            this.panelTechnics.Visible = false;
            this.panel1.Visible = false;
            this.groupBoxSetting.Visible = true;
            this.btnOk.Enabled = true;
            base.AcceptButton = this.btnOk;
            this.chkSaveCode.Focus();
        }

        private void menuTechnics_Click(object sender, EventArgs e)
        {
            base.Width = 776;
            this.groupBoxSetting.Visible = false;
            this.panelTechnics.Visible = true;
            this.panelTechnics.Left = 374;
            this.panel1.Visible = true;
            this.panel1.Left = 374;
            this.dgProductTechnics.AutoResizeColumns();
            this.dgProductTechnics.Focus();
            this.cbTechnicsName.Focus();
            base.AcceptButton = null;
        }

        private void menuGetBackForm_Click(object sender, EventArgs e)
        {
            this.panelTechnics.Visible = false;
            this.panel1.Visible = false;
            this.groupBoxSetting.Visible = false;
            this.btnOk.Enabled = true;
            base.AcceptButton = this.btnOk;
            this.btnOk.Focus();
            base.Width = 400;
        }

        private void menuLeftEdit_Click(object sender, EventArgs e)
        {
            base.AcceptButton = this.btnOk;
        }

        private void dgProductTechnics_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (!this.ckbDeleteTechnics.Checked)
            {
                int num = 0;
                int num2 = 0;
                int x = this.dgProductTechnics.Location.X;
                int y = this.dgProductTechnics.Location.Y;
                int x2 = this.dgProductTechnics.GetCellDisplayRectangle(this.dgProductTechnics.CurrentCell.ColumnIndex, this.dgProductTechnics.CurrentCell.RowIndex, false).X;
                int y2 = this.dgProductTechnics.GetCellDisplayRectangle(this.dgProductTechnics.CurrentCell.ColumnIndex, this.dgProductTechnics.CurrentCell.RowIndex, false).Y;
                int width = this.dgProductTechnics.GetCellDisplayRectangle(this.dgProductTechnics.CurrentCell.ColumnIndex, this.dgProductTechnics.CurrentCell.RowIndex, false).Width;
                int height = this.dgProductTechnics.GetCellDisplayRectangle(this.dgProductTechnics.CurrentCell.ColumnIndex, this.dgProductTechnics.CurrentCell.RowIndex, false).Height;
                if (this.dgProductTechnics.CurrentCell.ColumnIndex == 0)
                {
                    this.cbTechnicsName.Text = ((this.dgProductTechnics.CurrentCell.Value == null) ? "" : this.dgProductTechnics.CurrentCell.Value.ToString());
                    this.cbTechnicsName.Visible = true;
                    this.cbTechnicsName.Left = num + x + x2;
                    this.cbTechnicsName.Top = num2 + y + y2 + 1;
                    this.cbTechnicsName.Width = width;
                    this.cbTechnicsName.Height = height;
                    this.cbTechnicsName.Focus();
                }
                else
                {
                    this.cbTechnicsName.Hide();
                }
                if (this.dgProductTechnics.CurrentCell.ColumnIndex == 1 || this.dgProductTechnics.CurrentCell.ColumnIndex == 2 || this.dgProductTechnics.CurrentCell.ColumnIndex == 3)
                {
                    this.txt.Text = ((this.dgProductTechnics.CurrentCell.Value == null) ? "" : this.dgProductTechnics.CurrentCell.Value.ToString());
                    this.txt.Visible = true;
                    this.txt.Left = num + x + x2;
                    this.txt.Top = num + y + y2 + 1;
                    this.txt.Width = width;
                    this.txt.Height = height;
                    this.txt.Focus();
                    this.txt.SelectAll();
                }
                else
                {
                    this.txt.Hide();
                }
                if (this.dgProductTechnics.CurrentCell.ColumnIndex == 4)
                {
                    this.ckb.Checked = (this.dgProductTechnics.CurrentCell.Value != null && (bool)this.dgProductTechnics.CurrentCell.Value);
                    this.ckb.Visible = true;
                    this.ckb.Left = num + x + x2;
                    this.ckb.Top = num + y + y2;
                    this.ckb.Width = width;
                    this.ckb.Height = height;
                    this.ckb.Focus();
                }
                else
                {
                    this.ckb.Hide();
                }
            }
        }

        private void dgProductTechnics_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r' && this.nColumnIndex == this.dgProductTechnics.Columns.Count - 1 && this.nRowIndex < this.dgProductTechnics.Rows.Count - 1)
            {
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[this.nRowIndex + 1].Cells[0];
            }
            else if (e.KeyChar == '\r' && this.nColumnIndex == this.dgProductTechnics.Columns.Count - 1 && this.nRowIndex == this.dgProductTechnics.Rows.Count - 1)
            {
                this.dgProductTechnics.Rows.Add();
                this.dgProductTechnics.Rows[this.dgProductTechnics.Rows.Count - 2].SetValues(new object[]
                {
                    this.dgProductTechnics.Rows[this.dgProductTechnics.Rows.Count - 1].Cells[0].Value,
                    this.dgProductTechnics.Rows[this.dgProductTechnics.Rows.Count - 1].Cells[1].Value,
                    this.dgProductTechnics.Rows[this.dgProductTechnics.Rows.Count - 1].Cells[2].Value,
                    this.dgProductTechnics.Rows[this.dgProductTechnics.Rows.Count - 1].Cells[3].Value,
                    true
                });
                this.dgProductTechnics.Rows[this.dgProductTechnics.Rows.Count - 1].SetValues(new object[]
                {
                    null,
                    null,
                    null,
                    null,
                    false
                });
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[this.dgProductTechnics.Rows.Count - 1].Cells[0];
                this.dgProductTechnics.AutoResizeColumns();
            }
        }

        private void dgProductTechnics_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Right)
            {
                if (this.dgProductTechnics.CurrentCell.ColumnIndex == this.dgProductTechnics.Columns.Count - 1 && this.dgProductTechnics.CurrentCell.RowIndex < this.dgProductTechnics.Rows.Count - 1)
                {
                    this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[this.dgProductTechnics.CurrentCell.RowIndex + 1].Cells[0];
                }
            }
            this.nRowIndex = this.dgProductTechnics.CurrentCell.RowIndex;
            this.nColumnIndex = this.dgProductTechnics.CurrentCell.ColumnIndex;
        }

        private void cbTechnicsName_TextChanged(object sender, EventArgs e)
        {
            this.dgProductTechnics.CurrentCell.Value = this.cbTechnicsName.Text;
        }

        private void cbTechnicsName_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[this.dgProductTechnics.CurrentCell.RowIndex].Cells[this.dgProductTechnics.CurrentCell.ColumnIndex + 1];
            }
        }

        private void cbTechnicsName_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Right)
            {
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[this.dgProductTechnics.CurrentCell.RowIndex].Cells[this.dgProductTechnics.CurrentCell.ColumnIndex + 1];
            }
            if (e.KeyCode == Keys.Left && this.dgProductTechnics.CurrentCell.RowIndex > 0)
            {
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[this.dgProductTechnics.CurrentCell.RowIndex - 1].Cells[this.dgProductTechnics.Columns.Count - 1];
            }
            if (e.KeyCode == Keys.Left && this.dgProductTechnics.CurrentCell.RowIndex == 0 && this.dgProductTechnics.CurrentCell.ColumnIndex == 0)
            {
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[this.dgProductTechnics.Rows.Count - 1].Cells[this.dgProductTechnics.Columns.Count - 1];
            }
        }

        private void txt_TextChanged(object sender, EventArgs e)
        {
            this.dgProductTechnics.CurrentCell.Value = this.txt.Text;
        }

        private void txt_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[this.dgProductTechnics.CurrentCell.RowIndex].Cells[this.dgProductTechnics.CurrentCell.ColumnIndex + 1];
            }
        }

        private void txt_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Right)
            {
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[this.dgProductTechnics.CurrentCell.RowIndex].Cells[this.dgProductTechnics.CurrentCell.ColumnIndex + 1];
            }
            else if (e.KeyCode == Keys.Left)
            {
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[this.dgProductTechnics.CurrentCell.RowIndex].Cells[this.dgProductTechnics.CurrentCell.ColumnIndex - 1];
            }
            else if (e.KeyCode == Keys.Up && this.dgProductTechnics.CurrentCell.RowIndex > 0)
            {
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[this.dgProductTechnics.CurrentCell.RowIndex - 1].Cells[this.dgProductTechnics.CurrentCell.ColumnIndex];
            }
            else if (e.KeyCode == Keys.Down && this.dgProductTechnics.CurrentCell.RowIndex < this.dgProductTechnics.Rows.Count - 1)
            {
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[this.dgProductTechnics.CurrentCell.RowIndex + 1].Cells[this.dgProductTechnics.CurrentCell.ColumnIndex];
            }
        }

        private void ckb_CheckedChanged(object sender, EventArgs e)
        {
            this.dgProductTechnics.CurrentCell.Value = this.ckb.Checked;
        }

        private void ckb_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r' && this.dgProductTechnics.CurrentCell.ColumnIndex == this.dgProductTechnics.Columns.Count - 1 && this.dgProductTechnics.CurrentCell.RowIndex < this.dgProductTechnics.Rows.Count - 1)
            {
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[this.dgProductTechnics.CurrentCell.RowIndex + 1].Cells[0];
            }
            else if (e.KeyChar == '\r' && this.dgProductTechnics.CurrentCell.ColumnIndex == this.dgProductTechnics.Columns.Count - 1 && this.dgProductTechnics.CurrentCell.RowIndex == this.dgProductTechnics.Rows.Count - 1)
            {
                this.dgProductTechnics.Rows.Add();
                this.dgProductTechnics.Rows[this.dgProductTechnics.Rows.Count - 2].SetValues(new object[]
                {
                    this.dgProductTechnics.Rows[this.dgProductTechnics.Rows.Count - 1].Cells[0].Value,
                    this.dgProductTechnics.Rows[this.dgProductTechnics.Rows.Count - 1].Cells[1].Value,
                    this.dgProductTechnics.Rows[this.dgProductTechnics.Rows.Count - 1].Cells[2].Value,
                    this.dgProductTechnics.Rows[this.dgProductTechnics.Rows.Count - 1].Cells[3].Value,
                    true
                });
                this.dgProductTechnics.Rows[this.dgProductTechnics.Rows.Count - 1].SetValues(new object[]
                {
                    null,
                    null,
                    null,
                    null,
                    false
                });
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[this.dgProductTechnics.Rows.Count - 1].Cells[0];
                this.dgProductTechnics.AutoResizeColumns();
            }
        }

        private void ckb_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Right && this.dgProductTechnics.CurrentCell.RowIndex < this.dgProductTechnics.Rows.Count - 1)
            {
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[this.dgProductTechnics.CurrentCell.RowIndex + 1].Cells[0];
            }
            if (e.KeyCode == Keys.Right && this.dgProductTechnics.CurrentCell.RowIndex == this.dgProductTechnics.Rows.Count - 1 && this.dgProductTechnics.CurrentCell.ColumnIndex == this.dgProductTechnics.Columns.Count - 1)
            {
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[0].Cells[0];
            }
            if (e.KeyCode == Keys.Left)
            {
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[this.dgProductTechnics.CurrentCell.RowIndex].Cells[this.dgProductTechnics.CurrentCell.ColumnIndex - 1];
            }
            if (e.KeyCode == Keys.Up && this.dgProductTechnics.CurrentCell.RowIndex > 0)
            {
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[this.dgProductTechnics.CurrentCell.RowIndex - 1].Cells[this.dgProductTechnics.CurrentCell.ColumnIndex];
            }
            if (e.KeyCode == Keys.Down && this.dgProductTechnics.CurrentCell.RowIndex < this.dgProductTechnics.Rows.Count - 1)
            {
                this.dgProductTechnics.CurrentCell = this.dgProductTechnics.Rows[this.dgProductTechnics.CurrentCell.RowIndex + 1].Cells[this.dgProductTechnics.CurrentCell.ColumnIndex];
            }
        }

        private void ckbDeleteTechnics_CheckedChanged(object sender, EventArgs e)
        {
            if (this.ckbDeleteTechnics.Checked)
            {
                this.cbTechnicsName.Hide();
                this.txt.Hide();
                this.ckb.Hide();
            }
        }
    }
}
